//
//  GCD.swift
//  MGExtensionsKit
//
//  Created by Max on 2019/12/16.
//

import Foundation

/// async after in main queue
public func delay(_ delay: TimeInterval, closure: @escaping () -> ()) {
    DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: closure)
}

/// like @synchronized
public func synchronized(_ objc: Any, closure: () -> ()) {
    objc_sync_enter(objc)
    closure()
    objc_sync_exit(objc)
}
